# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: xguo

import coin.exchange.bitmex.kr_rest.private_client as privc
from coin.exchange.bitmex.kr_rest.futures_product import BitmexFuturesProduct
from coin.exchange.base.kr_rest.order_base import OrderBase


class BitmexOrder(OrderBase):
  ProductType = BitmexFuturesProduct

  def __init__(self, products, key_file, timeout=5, test=False):
    OrderBase.__init__(self, products, key_file)
    self.client = privc.BitmexPrivateClient(key_file=key_file, timeout=timeout, test=test)
    self.last_order = None

  def query_balance_impl(self):
    return self.client.query_account_balance()

  def query_submit(self, product, side, price, qty):
    return self.client.query_submit(product, side, price, qty)

  def query_cancel(self, product, order_id):
    return self.client.query_cancel(order_id)

  def query_cancel_product(self, product):
    return self.client.query_cancel_product(product)

  def query_list_orders(self, product=None):
    return self.client.query_list_orders()
